package remove

import (
	"fmt"
	"github.com/Exleryz/m3u8/constant"
	"os"
)

// DeleteFile 代码删除文件
func DeleteFile(count int, dirName, suffixName string) {
	/*for {
		time.Sleep(1 * time.Second)
		// todo

	}*/
	format := "%d.%s"
	if dirName != "" {
		format = "%s/%d.%s"
	}
	for i := 0; i < count; i++ {
		// 删除文件
		fileName := fmt.Sprintf(format, dirName, i, suffixName)
		if dirName == "" {
			fileName = fmt.Sprintf(format, i, suffixName)
		}
		os.Remove(fileName)
	}

	os.Remove(fmt.Sprintf("%s/%s", dirName, constant.FfmpegFileIndex))
}
